import os
import random

def generate_test_case(n, small_range=False):
    """
    生成一个测试用例：
      - n: 申请的社团数量
      - small_range: 若为 True，则 a, b 在 [0, 1000] 内；否则 a, b 在 [0, 10^9] 内。
    """
    intervals = []
    max_val = 1000 if small_range else 10**9
    for _ in range(n):
        a = random.randint(0, max_val - 1)
        b = random.randint(a + 1, max_val)  # 确保 a < b
        intervals.append((a, b))
    return n, intervals

def save_test_case(file_path, n, intervals):
    """
    将测试用例保存到指定文件中
    """
    with open(file_path, "w") as f:
        f.write(f"{n}\n")
        for a, b in intervals:
            f.write(f"{a} {b}\n")

def main():
    # 指定存放测试用例的目录
    output_dir = r"C:\Users\ASUS\Desktop\2025-BBUCPC\2025校赛出题\C题\C_inputs"
    os.makedirs(output_dir, exist_ok=True)
    
    num_cases = 20
    for i in range(1, num_cases + 1):
        if i <= int(num_cases * 0.4):  # 前 40% 测试点
            n = random.randint(80, 500)
            small_range = True
        else:  # 剩余 60% 测试点
            n = random.randint(501, 100000)
            small_range = False
        
        n_val, intervals = generate_test_case(n, small_range)
        file_path = os.path.join(output_dir, f"{i}.in")
        save_test_case(file_path, n_val, intervals)

if __name__ == "__main__":
    main()
